/****************************************************************************
*
*					Functions of class FeatureFactory
*
****************************************************************************/

#include <iostream>
#include "FeatureFactory.h"
#include "AllFeatureClasses.h"


/****************************************************************************
*					FeatureFactory::FeatureFactory
*
*	Description:	Standard constructor with initialization of internal parameters
*	Parameters:		-
*	Returns:		-
*
****************************************************************************/
FeatureFactory::FeatureFactory (void) {
	
}


/****************************************************************************
*					FeatureFactory::~FeatureFactory
*
*	Description:	Standard destructor with removing all dynamic internal variables
*	Parameters:		-
*	Returns:		-
*
****************************************************************************/
FeatureFactory::~FeatureFactory (void) {
	
}


/****************************************************************************
*					FeatureFactory::createObjectByID
*
*	Description:	Function creates object of ancestor class Feature
*					of a subclass with a given ID
*	Parameters:		id - identificator of subclass of class Feature
*	Returns:		Feature* - new dynamic object of subclass of 
*		  					   Feature with the given ID
*
****************************************************************************/
Feature* FeatureFactory::createObjectByID(const signed int id) {
	switch (id) { 
	case 1: 
		return new SimpleFeature();
	case 2: 
		return new ReciprocityFeature();
	default: 
		std::cout << "Error in FeatureFactory::createObjectByID: no feature with id = " << id << ".\n";
	}
	Feature* feature = NULL;
	return feature;
}


/****************************************************************************
*					FeatureFactory::createObjectByName
*
*	Description:	Function creates object of ancestor class Feature
*					of a subclass with a given name
*	Parameters:		name - name of the desired subclass of class Feature
*	Returns:		Feature* - new dynamic object of subclass of 
*							   Feature with the given name
*
****************************************************************************/
Feature* FeatureFactory::createObjectByName(const std::string name) {
	Feature* feature = NULL;
	// Transforming to lowercase
	std::string nameStr (name);
	std::transform(nameStr.begin(), nameStr.end(), nameStr.begin(), ::tolower);
	
	// Comparing the names
	if (strcmp (nameStr.c_str(), "simple") == 0) {
		return new SimpleFeature();
	}

	if (strcmp (nameStr.c_str(), "indegreepopularity") == 0) {
		return new IndegreePopularityFeature();
	}

	if (strcmp (nameStr.c_str(), "similarityx") == 0) {
		return new SimilarityXFeature();
	}

	if (strcmp (nameStr.c_str(), "similarityy") == 0) {
		return new SimilarityYFeature();
	}

	if (strcmp (nameStr.c_str(), "reciprocity") == 0) {
		return new ReciprocityFeature();
	}

	if (strcmp (nameStr.c_str(), "outdegreex") == 0) {
		return new OutdegreeXFeature();
	}

	if (strcmp (nameStr.c_str(), "outdegreey") == 0) {
		return new OutdegreeYFeature();
	}

	if (strcmp (nameStr.c_str(), "tripletxyy") == 0) {
		return new TripletXYYFeature();
	}

	if (strcmp (nameStr.c_str(), "transitiveinfosharing") == 0) {
		return new TransitiveInfoSharingFeature();
	}

	if (strcmp (nameStr.c_str(), "threecyclexyy") == 0) {
		return new ThreeCycleXYYFeature();
	}

	if (strcmp (nameStr.c_str(), "similarityx") == 0) {
		return new SimilarityXFeature();
	}

	if (strcmp (nameStr.c_str(), "similarityy") == 0) {
		return new SimilarityYFeature();
	}

	if (strcmp (nameStr.c_str(), "outdegreepopularityx") == 0) {
		return new OutdegreePopularityXFeature();
	}

	if (strcmp (nameStr.c_str(), "outdegreepopularityy") == 0) {
		return new OutdegreePopularityYFeature();
	}

	if (strcmp (nameStr.c_str(), "indegreepopularity") == 0) {
		return new IndegreePopularityFeature();
	}

	if (strcmp (nameStr.c_str(), "curiosityrule") == 0) {
		return new CuriosityRuleFeature();
	}

	if (strcmp (nameStr.c_str(), "communityeffect") == 0) {
		return new CommunityEffectFeature();
	}

	if (strcmp (nameStr.c_str(), "celebrityrule") == 0) {
		return new CelebrityRuleFeature();
	}

	if (strcmp (nameStr.c_str(), "balance") == 0) {
		return new BalanceFeature();
	}

	if (strcmp (nameStr.c_str(), "tripletxxx") == 0) {
		return new TripletXXXFeature();
	}

	if (strcmp (nameStr.c_str(), "tripletxxy") == 0) {
		return new TripletXXYFeature();
	}

	// Add new features here:

	// Should not get here:
	std::cout << "\nError in FeatureFactory::createObjectByName: no feature with name '" << name << "' is known to the factory.\n";
	return feature;
}
